package Manager.Help;

import java.awt.*;
import java.sql.*;

import javax.swing.*;
import javax.swing.border.*;

import Database.*;
import Exception.*;

public class PanelLogs extends JPanel
{
	private JButton buttonBack, buttonAddition, buttonModification, buttonSuppression, buttonNext;
	private JTextField fieldLogin, fieldPassword, fieldFirstName, fieldLastName, fieldUserType;
	
	//test
	private CallDB callDB;
	
	public PanelLogs() throws LoadDriverException
	{
		setLayout(null);
		setBorder(new BevelBorder(BevelBorder.RAISED, Color.ORANGE, Color.RED, Color.BLUE, Color.BLACK));
		
		callDB = new CallDB();
		
		fieldLogin = new JTextField("");
		fieldLogin.setBounds(41, 200, 100, 35);
		
		fieldPassword = new JTextField("");
		fieldPassword.setBounds(182, 200, 100, 35);
		
		fieldFirstName = new JTextField("");
		fieldFirstName.setBounds(323, 200, 100, 35);
		
		fieldLastName = new JTextField("");
		fieldLastName.setBounds(464, 200, 100, 35);
		
		fieldUserType = new JTextField("");
		fieldUserType.setBounds(605, 200, 100, 35);
		
		showComponent();
	}
	
	public JButton getButtonBack()
	{
		return this.buttonBack;
	}
	
	public JButton getButtonAddition()
	{
		return this.buttonAddition;
	}
	
	public JButton getButtonModification()
	{
		return this.buttonModification;
	}
	
	public JButton getButtonSuppression()
	{
		return this.buttonSuppression;
	}
	
	public JButton getButtonNext()
	{
		return this.buttonNext;
	}
	
	public void checkAndAdd(Connection connection) throws InsertionDataException, OpenConnectionException, NumberFormatException
	{
		fieldLogin.getText();
		fieldPassword.getText();
		fieldFirstName.getText();
		fieldLastName.getText();

		Integer.parseInt(fieldUserType.getText());
		
		/*if(userType != 1 && userType != 2)
			System.out.println("error");
		else
			userType = 1;*/
	}
	
	/*public void deleteAccount(Connection connection) throws EraseDataException
	{
		String login = fieldLogin.getText();
		callDB.delAccount(connection, login);
	}*/
	
	public void showComponent()
	{
		buttonBack = new JButton("Back");
		buttonBack.setBounds(50, 260, 100, 35);
		buttonBack.setFont(new Font("Constantia", Font.ITALIC, 22));

		buttonAddition = new JButton("Addition");
		buttonAddition.setBounds(67, 154, 160, 35);
		buttonAddition.setFont(new Font("Constantia", Font.ITALIC, 22));
		
		buttonModification = new JButton("Modification");
		buttonModification.setBounds(294, 154, 160, 35);
		buttonModification.setFont(new Font("Constantia", Font.ITALIC, 22));
		
		buttonSuppression = new JButton("Suppression");
		buttonSuppression.setBounds(521, 154, 160, 35);
		buttonSuppression.setFont(new Font("Constantia", Font.ITALIC, 22));
		
		buttonNext = new JButton("Next");
		buttonNext.setBounds(600, 260, 100, 35);
		buttonNext.setFont(new Font("Constantia", Font.ITALIC, 22));
		
		this.add(buttonBack);
		this.add(buttonAddition);
		this.add(buttonModification);
		this.add(buttonSuppression);
		this.add(buttonNext);
		this.add(fieldLogin);
		this.add(fieldPassword);
		this.add(fieldFirstName);
		this.add(fieldLastName);
		this.add(fieldUserType);
	}
}